<div class="row m-n">
	<div class="crumbs-bar">
		<div yb-crumbs></div>
	</div>
	<div tabset type="tab">
		<div tab heading="商机管理" active="activeFlag[0]" ng-click="changeTab(0)">
			<div class="row wrapper-y-sm">
				<div class="operate-bar col-xs-4 font-0">
					<button class="btn btn-operate m-r-sm" ng-disabled="" ng-click="addBusiness()">新增</button>
					<button class="btn btn-operate m-r-sm" ng-disabled="" ng-click="removeBusiness()">删除</button>
				</div>
				<div class="search-bar wrapper-none col-xs-8">
					<div class="btn-group m-l-xs pull-right">
						<button type="button" class="btn btn-default base-color" ng-click="search()" title="刷新">
							<i class="yb-icon ico-refresh"></i>
						</button>
						<button type="button" class="btn btn-default base-color" title="配置表格列" ng-click="switchToolbar('ColConfig');">
							<i class="yb-icon ico-set"></i>
						</button>
						<button type="button" ng-if="" class="btn btn-default base-color" title="导入">
							<i class="yb-icon ico-import-o"></i>
						</button>
						<div class="btn btn-default base-color" ng-if="">
							<div title="导出" yb-download download-url="" download-param="condition" download-duration="3">
								<i class="yb-icon ico-export-o"></i>
							</div>
						</div>
					</div>
					<button class="btn-advance pull-right m-l-xs" ng-click="switchToolbar('AdvanceSearch')">高级搜索</button>
					<div class="input-group pull-right clearfix">
						<input type="text" class="form-control txt-search" placeholder="商机单号" ng-model="condition.buCode">
						<span class="input-group-addon cursor-pointer" ng-click="search(1)">搜索</span>
					</div>
				</div>
			</div>
			<!-- 高级搜索 -->
			<div yb-advance-search show-toolbar="toolbarConfig.showAdvanceSearch" search-data="search(1)" reset-data="reset()">
				<div class="advance-search m-t-sm">
					<div class="form-group clearfix">
						<label class="control-label">商机单号：</label>
						<input type="text" name="" ng-model="condition.buCode" class="form-control">
					</div>
					<div class="form-group clearfix">
						<label class="control-label">商机状态：</label>
						<select class="form-control" ng-init="condition.buState = ''" ng-model="condition.buState">
							<option value="">请选择</option>
							<option value="0">初始</option>
							<option value="2">已丢单</option>
							<option value="3">已赢单</option>
						</select>
					</div>
					<div class="form-group clearfix">
						<label class="control-label">联系人</label>
						<input type="text" name="" ng-model="condition.linkman" class="form-control">
					</div>
					<div class="form-group clearfix">
						<label class="control-label">crm单号</label>
						<input type="text" name="" ng-model="condition.crmOrder" class="form-control">
				</div>
				</div>
			</div>
			<!-- 配置表格列 -->
			<div yb-col-config show-toolbar="toolbarConfig.showColConfig" ng-model="tableConfig" col-fixed="true"
            has-check-col="true" set-tb-style="setFixedWidth()"></div>
			<div class="main-area">
				<div yb-table-fixed class="table-fixed-wrap fix-left" ele-count="4" scroll-area="right">
					<div class="th-fixed">
						<table class="table-fixed border-none" width="{{tableConfig.fixedWidth}}">
							<thead>
								<tr>
									<th width="40" class="th-check text-center border-l-none">
										<div yb-check-box yb-checked="markInfo.allChecked" yb-click="selectAll(dataList, 'Bill')"></div>
									</th>
									<th class="border-l-none" ng-repeat="itemCol in tableConfig.tableCol track by $index" width="{{itemCol.width}}"
									 ng-click="toSort(tableConfig.tableCol, $index)" ng-show="!!itemCol.isShow && !!itemCol.isFixed">
										<div yb-thead-operate ng-model="itemCol" target-width="tableConfig.fixedWidth" fixed-width="tbStyle.billFixedWidth"></div>
									</th>
								</tr>
							</thead>
						</table>
					</div>
					<div class="th-scroll-x" ng-style="tbStyle.scrollLeft">
						<table class="table-fixed border-none" width="{{tableConfig.scrollWidth}}">
							<thead>
								<tr>
									<th ng-repeat="itemCol in tableConfig.tableCol track by $index" width="{{itemCol.width}}" ng-click="toSort(tableConfig.tableCol, $index)"
									 ng-show="!!itemCol.isShow && !itemCol.isFixed">
										<div yb-thead-operate ng-model="itemCol" target-width="tableConfig.scrollWidth"></div>
									</th>
								</tr>
							</thead>
						</table>
					</div>
					<div class="td-scroll-y" ng-show="dataList.length > 0">
						<table class="table-fixed border-none" width="{{tableConfig.fixedWidth}}">
							<tbody>
								<tr ng-repeat="item in dataList track by $index" ng-class="{'row-selected': $index === markInfo.cueRow}"
								 ng-click="selectRow($index)">
									<td width="40" class="text-center border-l-none">
										<div yb-check-box yb-checked="item.isChecked" yb-click="selectSingle(item, dataList)"></div>
									</td>
									<td class="spill-dots border-l-none" ng-repeat="itemCol in tableConfig.tableCol track by $index" width="{{itemCol.width}}"
									 ng-show="!!itemCol.isShow && !!itemCol.isFixed" title="{{item[itemCol.dataField]}}">
										<span ng-if="!itemCol.clickFn && itemCol.type !== 'operate'">{{item[itemCol.dataField]}}{{itemCol.type}}</span>
										<a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)" ng-if="!!itemCol.clickFn">
											{{item[itemCol.dataField]}}
										</a>
										<div class="font-0" ng-if="itemCol.type === 'operate'">
											<button class="btn btn-operate m-r-xs" ng-disabled="item.buState !== '0' " ng-click="editBusiness(item)">编辑</button>
											<button class="btn btn-operate m-r-xs" ng-disabled="item.buState !== '0' " ng-click="lostWin(item,'2')">丢单</button>
											<button class="btn btn-operate m-r-xs" ng-disabled="item.buState !== '0' " ng-click="lostWin(item,'3')">赢单</button>
										</div>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
					<div class="td-scroll" ng-show="dataList.length > 0" ng-style="tbStyle.scrollLeft">
						<table class="table-fixed border-none" width="{{tableConfig.scrollWidth}}">
							<tbody>
								<tr ng-repeat="item in dataList track by $index" ng-class="{'row-selected': $index === markInfo.cueRow}"
								 ng-click="selectRow($index)">
									<td class="spill-dots" ng-repeat="itemCol in tableConfig.tableCol track by $index" width="{{itemCol.width}}"
									 ng-show="!!itemCol.isShow && !itemCol.isFixed" title="{{item[itemCol.dataField]}}">
										<div class="spill-dots" ng-if="(!itemCol.isInput&&!itemCol.isRemark) || item.status == 2 || item.status == 3"
										 title="{{item[itemCol.dataField]}}">
											<a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)" ng-if="!!itemCol.clickFn">
												{{item[itemCol.dataField]}}
											</a>
											<span ng-if="!itemCol.clickFn && !(itemCol.dataField == 'buState')">
												{{item[itemCol.dataField]}}
											</span>
											<span ng-if="item[itemCol.dataField] == '0' && itemCol.dataField == 'buState'">初始</span>
											<span ng-if="item[itemCol.dataField] == '1' && itemCol.dataField == 'buState'">跟单中</span>
											<span ng-if="item[itemCol.dataField] == '2' && itemCol.dataField == 'buState'">已丢单</span>
											<span ng-if="item[itemCol.dataField] == '3' && itemCol.dataField == 'buState'">已赢单</span>
											<span ng-if="item[itemCol.dataField] == '4' && itemCol.dataField == 'buState'">已转销售</span>
										</div>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
					<div class="no-data w-full text-center p-t" ng-show="dataList.length === 0">暂时没有数据</div>
				</div>
			</div>
			<!-- 分页 -->
			<div class="bottom-area page-bar wrapper-y-sm clearfix">
				<div yb-check-box class="m-t-xs m-r-sm" yb-checked="markInfo.allChecked" yb-check-name="全选" yb-click="selectAll()"></div>
				<button class="btn btn-operate" ng-click="delData('batch')" ng-disabled="!btnPermission.clientDel||markInfo.crmCodeAll" title="{{!btnPermission.clientDel?'无权限执行此操作':''}}">删除</button>
				<div yb-page-info ng-model="pageInfo" yb-refresh="search()"></div>
			</div>
		</div>
		<!-- 新增、编辑 -->
		<div tab heading="{{tabFlag.name}}" active="activeFlag[1]" ng-if="activeFlag[1]">
			<form name="form" class="m-t-sm form-horizontal form-up-tb border-b clearfix" novalidate>
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 control-label max-w-100">商机单号：</label>
					<div ng-if="tabFlag.name == '新增'" class="col-xs-8 control-label p-l-n text-left spill-dots" title="">
						{{ '-' }}
					</div>
					<div ng-if="tabFlag.name == '编辑'" class="col-xs-8 control-label p-l-n text-left spill-dots" title="">
						{{ businessForms.buCode || '-' }}
					</div>
				</div>
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 control-label max-w-100">创建人：</label>
					<div class="col-xs-8 control-label p-l-n text-left spill-dots" title="">
							{{ curUser.name || '-' }}
					</div>
				</div>
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 control-label max-w-100">创建日期：</label>
					<div ng-if="tabFlag.name == '新增'" class="col-xs-8 control-label p-l-n text-left spill-dots" title="">
						{{ currentDate || '-' }}
					</div>
					<div ng-if="tabFlag.name == '编辑'" class="col-xs-8 control-label p-l-n text-left spill-dots" title="">
							{{ businessForms.createTime || '-' }}
					</div>
				</div>
				<div class="form-group col-xs-3 m-b-sm" style="height: 34px;"></div>
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 control-label max-w-100"><i>*</i>潜在客户：</label>
					<div class="col-xs-8 wrapper-none">
						<input type="text" name="customer" class="form-control" required yb-focus maxlength="20" ng-model="businessForms.customer">
						<div class="col-xs-8 msg-block"
								 ng-show="form.customer.$dirty || (form.customer.$invalid && submitted)">
								<div class="error-msg"
											ng-if="form.customer.$error.required && !form.customer.focused">
										<i class="yb-icon ico-times-circular"></i>必填项，请填写
								</div>
						</div>
					</div>
				</div>
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 control-label max-w-100"><i>*</i>客户联系人：</label>
					<div class="col-xs-8 wrapper-none">
						<input type="text" name="linkman" class="form-control" required yb-focus maxlength="20" ng-model="businessForms.linkman">
						<div class="col-xs-8 msg-block"
								 ng-show="form.linkman.$dirty || (form.linkman.$invalid && submitted)">
								<div class="error-msg"
											ng-if="form.linkman.$error.required && !form.linkman.focused">
										<i class="yb-icon ico-times-circular"></i>必填项，请填写
								</div>
						</div>
					</div>
				</div>
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 control-label max-w-100"><i>*</i>客户联系方式：</label>
					<div class="col-xs-8 wrapper-none">
						<input type="text" name="phone" class="form-control" required yb-focus maxlength="20" ng-model="businessForms.phone">
						<div class="col-xs-8 msg-block"
								 ng-show="form.phone.$dirty || (form.phone.$invalid && submitted)">
								<div class="error-msg"
											ng-if="form.phone.$error.required && !form.phone.focused">
										<i class="yb-icon ico-times-circular"></i>必填项，请填写
								</div>
						</div>
					</div>
				</div>
				<div class="form-group col-xs-3 m-b-sm" style="height: 34px;"></div>
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 control-label max-w-100"><i>*</i>需求产品型号：</label>
					<div class="col-xs-8 wrapper-none">
						<input type="text" name="productType" class="form-control" required yb-focus maxlength="30" ng-model="businessForms.productType">
						<div class="col-xs-8 msg-block"
								 ng-show="form.productType.$dirty || (form.productType.$invalid && submitted)">
								<div class="error-msg"
											ng-if="form.productType.$error.required && !form.productType.focused">
										<i class="yb-icon ico-times-circular"></i>必填项，请填写
								</div>
						</div>
					</div>
				</div>
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 control-label max-w-100">产品组：</label>
					<div class="col-xs-8 wrapper-none">
						<input type="text" name="" class="form-control" yb-focus maxlength="20" ng-model="businessForms.productGroup">
					</div>
				</div>
			
				
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 control-label max-w-100">出厂编号：</label>
					<div class="col-xs-8 wrapper-none">
						<input type="text" name="" class="form-control" yb-focus maxlength="20" ng-model="businessForms.factoryNo">
					</div>
				</div>

				<div class="form-group col-xs-3 m-b-sm" style="height: 34px;"></div>
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 control-label max-w-100"><i>*</i>商机状态：</label>
					<div class="col-xs-8 wrapper-none">
						<select class="form-control" ng-disabled="1" required ng-init="businessForms.buState = 0" ng-model="businessForms.buState">
							<option value="0">初始</option>
							<option value="2">已丢单</option>
							<option value="3">已赢单</option>
						</select>
					</div>
				</div>

				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 control-label max-w-100">区域信息：</label>
					<div class="col-xs-8 wrapper-none">
						<input type="text" name="" class="form-control" yb-focus maxlength="50" ng-model="businessForms.regionInfo">
					</div>
				</div>

				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 control-label max-w-100">备注：</label>
					<div class="col-xs-8 wrapper-none">
						<input type="text" name="" class="form-control" yb-focus maxlength="200" ng-model="businessForms.remark">
					</div>
				</div>
			</form>
	
			<div class="bottom-area btn-bar text-center clearfix">
				<button type="button" class="btn btn-primary m-r-sm" ng-click="addBusinessForm(form.$valid)">保存</button>
				<button type="button" class="btn btn-default" ng-click="changeTab(0)">取消</button>
			</div>
		</div>
		<!-- 详情 -->
		<div tab heading="{{tabFlag.name}}" active="activeFlag[2]" ng-if="activeFlag[2]">
			<div class="m-t-sm form-up-tb clearfix">
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 m-b-n text-right max-w-100">商机单号：</label>
					<div class="col-xs-8 wrapper-none spill-dots" title="{{detailInfo.buCode}}">
						{{ detailInfo.buCode || '-' }}
					</div>
				</div>
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 m-b-n text-right max-w-100">创建人：</label>
					<div class="col-xs-8 wrapper-none spill-dots" title="{{detailInfo.createUser}}">
						{{ detailInfo.createUser || '-' }}
					</div>
				</div>
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 m-b-n text-right max-w-100">创建日期：</label>
					<div class="col-xs-8 wrapper-none spill-dots" title="{{detailInfo.createTime}}">
						{{ detailInfo.createTime|YbDate:"yyyy-MM-dd HH:mm:ss"  }}
					</div>
				</div>
				<div class="form-group col-xs-3 m-b-sm" style="height: 24px;"></div>

				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 m-b-n text-right max-w-100">潜在客户：</label>
					<div class="col-xs-8 wrapper-none spill-dots" title="{{detailInfo.customer}}">
						{{ detailInfo.customer || '-'  }}
					</div>
				</div>
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 m-b-n text-right max-w-100">客户联系人：</label>
					<div class="col-xs-8 wrapper-none spill-dots" title="{{detailInfo.linkman}}">
						{{ detailInfo.linkman || '-'  }}
					</div>
				</div>
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 m-b-n text-right max-w-100">客户联系方式：</label>
					<div class="col-xs-8 wrapper-none spill-dots" title="{{detailInfo.phone}}">
						{{ detailInfo.phone || '-'  }}
					</div>
				</div>
				<div class="form-group col-xs-3 m-b-sm" style="height: 24px;"></div>

				
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 m-b-n text-right max-w-100">需求产品型号：</label>
					<div class="col-xs-8 wrapper-none spill-dots" title="{{detailInfo.productType}}">
						{{ detailInfo.productType || '-'  }}
					</div>
				</div>
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 m-b-n text-right max-w-100">产品组：</label>
					<div class="col-xs-8 wrapper-none spill-dots" title="{{detailInfo.productGroup}}">
						{{ detailInfo.productGroup || '-'  }}
					</div>
				</div>
				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 m-b-n text-right max-w-100">出厂编号：</label>
					<div class="col-xs-8 wrapper-none spill-dots" title="{{detailInfo.factoryNo}}">
						{{ detailInfo.factoryNo || '-'  }}
					</div>
				</div>
				<div class="form-group col-xs-3 m-b-sm" style="height: 24px;"></div>

				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 m-b-n text-right max-w-100">商机状态：</label>
					<div ng-if="detailInfo.buState == 0" class="col-xs-8 wrapper-none spill-dots">初始</div>
					<div ng-if="detailInfo.buState == 2" class="col-xs-8 wrapper-none spill-dots">已丢单</div>
					<div ng-if="detailInfo.buState == 3" class="col-xs-8 wrapper-none spill-dots">已赢单</div>
				</div>

				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 m-b-n text-right max-w-100">区域信息：</label>
					<div class="col-xs-8 wrapper-none spill-dots" title="{{detailInfo.regionInfo}}">
						{{ detailInfo.regionInfo || '-'  }}
					</div>
				</div>

				<div class="form-group col-xs-3 m-b-sm">
					<label class="col-xs-4 m-b-n text-right max-w-100">备注：</label>
					<div class="col-xs-8 wrapper-none spill-dots" title="{{detailInfo.possibility}}">
						{{ detailInfo.remark || '-'  }}
					</div>
				</div>
				
			</div>
		
			<div class="bottom-area btn-bar text-center clearfix" style="position: inherit;">
				<button type="button" class="btn btn-default" ng-if="tabFlag.type === 1" ng-click="cancel()">返回</button>
			</div>
		</div>
	</div>
</div>
